#ifndef PANEL_H
#define PANEL_H

#include <QWidget>
#include <QPaintEvent>
#include <QTimer>

namespace Ui {
class Panel;
}

class Panel : public QWidget
{
    Q_OBJECT

public:
    explicit Panel(QString useMem,QWidget *parent = nullptr);
    ~Panel();

    void paintEvent(QPaintEvent *event) override;

private:
    Ui::Panel *ui;
    QTimer *timer;
    QString useMem;
    int num;
    int mark;
    double Angle;
    int StartAngle;

    //初始化画布 让背景为黑色
    void initCanvas(QPainter& painter);
    //画中间的小圆
    void drawMiddleCircle(QPainter &painter, int radius);
    //画出当前的速度
    void drawCurrentSpeed(QPainter &painter);
    //画刻度
    void drawScale(QPainter &painter, int radius);
    //画刻度的文字
    void drawScaleText(QPainter &painter, int radius);
    //画指针
    void drawPointLen(QPainter &painter, int len);
    //画扇形
    void drawSpeedPie(QPainter &painter, int radius);
    //在中间画一个黑色的圆圈
    void drawCircleBlack(QPainter &painter, int radius);
    //在中间画一个渐变的红色
    void drawCircleRed(QPainter &painter, int radius);
    //最外圈渐变色
    void drawOutCircle(QPainter &painter, int radius);
    //画一个宝马logo
    void drawLogo(QPainter &painter, int radius);
};

#endif // PANEL_H
